
<!DOCTYPE html>
<html lang="zh-CN" class="loading">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>github从本地上传文件到仓库 - peony&#39;s blogs</title>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="google" content="notranslate" />
    <meta name="keywords" content="peony,"> 
    <meta name="description" content="github从本地上传文件到仓库第一次用git传输，记录下来过程和问题。
1.右键打开git bash2.绑定gihub
git config –global user.name”XXXX”git ,"> 
    <meta name="author" content="peony"> 
    <link rel="alternative" href="atom.xml" title="peony&#39;s blogs" type="application/atom+xml"> 
    <link rel="icon" href="/img/favicon63.png"> 
    
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">

    
<link rel="stylesheet" href="/css/diaspora.css">

    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <script>
         (adsbygoogle = window.adsbygoogle || []).push({
              google_ad_client: "ca-pub-8691406134231910",
              enable_page_level_ads: true
         });
    </script>
    <script async custom-element="amp-auto-ads"
        src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js">
    </script>
<meta name="generator" content="Hexo 4.2.0"></head>

<body class="loading">
    <span id="config-title" style="display:none">peony&#39;s blogs</span>
    <div id="loader"></div>
    <div id="single">
    <div id="top" style="display: block;">
    <div class="bar" style="width: 0;"></div>
    <a class="icon-home image-icon" href="javascript:;" data-url="http://yoursite.com"></a>
    <div title="播放/暂停" class="icon-play"></div>
    <h3 class="subtitle">github从本地上传文件到仓库</h3>
    <div class="social">
        <!--<div class="like-icon">-->
            <!--<a href="javascript:;" class="likeThis active"><span class="icon-like"></span><span class="count">76</span></a>-->
        <!--</div>-->
        <div>
            <div class="share">
                <!--<a title="获取二维码" class="icon-scan" href="javascript:;" ></a>-->
            </div>
            <div id="qr"></div>
        </div>
    </div>
    <div class="scrollbar"></div>
</div>

    <div class="section">
        <div class="article">
    <div class='main'>
        <h1 class="title">github从本地上传文件到仓库</h1>
        <div class="stuff">
            <span>二月 23, 2020</span>
            

        </div>
        <div class="content markdown">
            <h1 id="github从本地上传文件到仓库"><a href="#github从本地上传文件到仓库" class="headerlink" title="github从本地上传文件到仓库"></a>github从本地上传文件到仓库</h1><p>第一次用git传输，记录下来过程和问题。</p>
<h2 id="1-右键打开git-bash"><a href="#1-右键打开git-bash" class="headerlink" title="1.右键打开git bash"></a>1.右键打开git bash</h2><h2 id="2-绑定gihub"><a href="#2-绑定gihub" class="headerlink" title="2.绑定gihub"></a>2.绑定gihub</h2><blockquote>
<p>git config –global user.name”XXXX”<br>git config –global user.email”<a href="mailto:XXXX@aa.com">XXXX@aa.com</a>“</p>
</blockquote>
<h2 id="3-在github网页上建立仓库"><a href="#3-在github网页上建立仓库" class="headerlink" title="3.在github网页上建立仓库"></a>3.在github网页上建立仓库</h2><p><img src="https://img-blog.csdnimg.cn/20200222135524346.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzE1NzY0NDc3,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<h2 id="4-复制仓库连接"><a href="#4-复制仓库连接" class="headerlink" title="4.复制仓库连接"></a>4.复制仓库连接</h2><p>在仓库里面找到cloneOrDownload那个绿色按钮，复制连接。</p>
<h2 id="5-开始准备本地文件"><a href="#5-开始准备本地文件" class="headerlink" title="5.开始准备本地文件"></a>5.开始准备本地文件</h2><h4 id="1-建立一个本地的文件夹作为仓库"><a href="#1-建立一个本地的文件夹作为仓库" class="headerlink" title="(1)建立一个本地的文件夹作为仓库"></a>(1)建立一个本地的文件夹作为仓库</h4><p>新建一个文件夹。在文件夹里面用git bash，这样就不用cd进入某个文件夹了。<br>然后输入指令</p>
<blockquote>
<p>git init<br>git add .<br>git commit -m “注释”</p>
</blockquote>
<p>git init会生成一个git.隐藏文件，git add会上传所有文件，commit会添加上传时候的注释。<br><img src="https://img-blog.csdnimg.cn/20200222140211155.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzE1NzY0NDc3,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"><br>这里我的git add .报错了。网上查完发现需要输入</p>
<blockquote>
<p>git config –global core.autocrlf false<br><img src="https://img-blog.csdnimg.cn/20200222140308958.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzE1NzY0NDc3,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
</blockquote>
<p>这样第一步就完成了</p>
<h4 id="2-上传文件"><a href="#2-上传文件" class="headerlink" title="(2)上传文件"></a>(2)上传文件</h4><p>写上下面的代码</p>
<blockquote>
<p>git remote add origin 第四步的仓库连接<br>git push -u origin master</p>
</blockquote>
<p><img src="https://img-blog.csdnimg.cn/20200222140647332.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzE1NzY0NDc3,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"></p>
<p>我没有配置ssh秘钥，所以第二部需要输入密码。<br>我第二步报错了HttpRequestException Encountered<br>需要输入下面的代码</p>
<blockquote>
<p>git pull<br>git push origin master -f</p>
</blockquote>
<p><img src="https://img-blog.csdnimg.cn/20200222140958107.PNG" alt="在这里插入图片描述"><br>这种问题应该是连不上网，墙太高了，隔几分钟试一次。</p>
<p><img src="https://img-blog.csdnimg.cn/20200222141150257.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzE1NzY0NDc3,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"><br><img src="https://img-blog.csdnimg.cn/20200222141159617.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzE1NzY0NDc3,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"><br>这回刷新仓库就有刚才传上去的文件了</p>
<h4 id="3-更新仓库"><a href="#3-更新仓库" class="headerlink" title="(3)更新仓库"></a>(3)更新仓库</h4><blockquote>
<p>git status<br>git add -A<br>git commit -a -m “update”<br>git push origin master -f</p>
</blockquote>
<p><img src="https://img-blog.csdnimg.cn/20200222141620746.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzE1NzY0NDc3,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"><br>我在本地仓库删除了一个文件，所以报红色，这不是异常。<br><img src="https://img-blog.csdnimg.cn/2020022214170092.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzE1NzY0NDc3,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"><br><img src="https://img-blog.csdnimg.cn/20200222141713651.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzE1NzY0NDc3,size_16,color_FFFFFF,t_70" alt="在这里插入图片描述"><br>至此修改成功</p>

            <!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->
            <audio id="audio" loop="1" preload="auto" controls="controls" data-autoplay="false">
                <source type="audio/mpeg" src="">
            </audio>
            
                <ul id="audio-list" style="display:none">
                    
                        
                            <li title='0' data-url='http://link.hhtjim.com/163/5146554.mp3'></li>
                        
                    
                        
                            <li title='1' data-url='http://link.hhtjim.com/qq/001faIUs4M2zna.mp3'></li>
                        
                    
                </ul>
            
        </div>
        
    <div id='gitalk-container' class="comment link"
        data-ae='false'
        data-ci='c82ee42088349c609c4d'
        data-cs='541eefaa06715f3b1bcd6bf41cb69a4053d18348'
        data-r='PPeony.github.io'
        data-o='PPeony'
        data-a='PPeony'
        data-d='false'
    >查看评论</div>


    </div>
    
</div>


    </div>
</div>
</body>

<script src="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>


<script src="//lib.baomitu.com/jquery/1.8.3/jquery.min.js"></script>
<script src="/js/plugin.js"></script>
<script src="/js/diaspora.js"></script>


<link rel="stylesheet" href="/photoswipe/photoswipe.css">
<link rel="stylesheet" href="/photoswipe/default-skin/default-skin.css">


<script src="/photoswipe/photoswipe.min.js"></script>
<script src="/photoswipe/photoswipe-ui-default.min.js"></script>


<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>
    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">
        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>
        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">
            <div class="pswp__top-bar">
                <!--  Controls are self-explanatory. Order can be changed. -->
                <div class="pswp__counter"></div>
                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
                <button class="pswp__button pswp__button--share" title="Share"></button>
                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                      <div class="pswp__preloader__cut">
                        <div class="pswp__preloader__donut"></div>
                      </div>
                    </div>
                </div>
            </div>
            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div> 
            </div>
            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>
            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>
            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>
        </div>
    </div>
</div>




</html>
